﻿using System;
using System.IO;
using System.Text.RegularExpressions;

class Program
{
    static void Main(string[] args)
    {
        Console.Write("请输入C#源文件的路径：");
        string filePath = Console.ReadLine();

        if (File.Exists(filePath))
        {
            int lineCount = 0;
            int wordCount = 0;

            string[] lines = File.ReadAllLines(filePath);

            foreach (string line in lines)
            {
                // 删除空行和注释（以"//"开头）
                string cleanedLine = line.Trim();
                if (!string.IsNullOrWhiteSpace(cleanedLine) && !cleanedLine.StartsWith("//"))
                {
                    lineCount++;

                    // 统计单词数（不包括空格、标点符号）
                    string[] words = Regex.Split(cleanedLine, @"\P{L}+");
                    wordCount += words.Length;
                }
            }

            Console.WriteLine("源文件的原始行数：" + lineCount);
            Console.WriteLine("源文件的单词数：" + wordCount);
        }
        else
        {
            Console.WriteLine("文件不存在！");
        }

        Console.ReadLine();
    }
}